package com.atguigu.tingshu.album.client;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.service.TrackInfoService;
import com.atguigu.tingshu.model.album.TrackInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/***
 * TrackFeign调用API
 */
@RestController
@RequestMapping("/client/track/trackInfo")
public class TrackClientController {
    @Autowired
    private TrackInfoService trackInfoService;


    /**
     * 查询声音是否存在
     * @param trackId
     * @return
     */
    @GetMapping("/getTrackInfo/{trackId}")
    public Boolean getTrackInfo(@PathVariable("trackId")Long trackId){
        return trackInfoService.getById(trackId)!=null;
    }

    /**
     * 查询声音的详细信息
     * @param trackId
     * @return
     */
    @GetMapping("/getTrackInfoDetail/{trackId}")
    public TrackInfo getTrackInfoDetail(@PathVariable("trackId")Long trackId){
        return trackInfoService.getById(trackId);
    }


    /**
     * 查询即将确认订单的声音
     * @param trackId
     * @return
     */
    @GetMapping("/getTrackListAndPrice/{trackId}")
    public JSONObject getTrackListAndPrice(@PathVariable("trackId")Long trackId){
        return trackInfoService.getTrackListAndPrice(trackId);
    }


    // TODO 订单取消



}
